Buffer file writing for dep-info
authorRaph Levien <raph@google.com>
Thu, 26 Jan 2017 21:12:14 +0000 (13:12 -0800)
committerRaph Levien <raph@google.com>
Thu, 26 Jan 2017 21:12:14 +0000 (13:12 -0800)
Use BufWriter when generating .d files with dep-info, to avoid
excessive numbers of write syscalls.

src/cargo/ops/cargo_rustc/output_depinfo.rs

index add28e023e31adf0a84575c9e446bc1c53b61251..5ed98eb11599548678f635d584da3b7e908396b3 100644 (file)
@@ -1,5 +1,5 @@
 use std::collections::HashSet;
-use std::io::Write;
+use std::io::{Write, BufWriter};
 use std::fs::File;
 use std::path::{Path, PathBuf};
 
@@ -53,7 +53,7 @@ pub fn output_depinfo<'a, 'b>(context: &mut Context<'a, 'b>, unit: &Unit<'a>) ->
         if let Some(link_dst) = link_dst {
             let output_path = link_dst.with_extension("d");
             let target_fn = render_filename(link_dst, basedir)?;
-            let mut outfile = File::create(output_path)?;
+            let mut outfile = BufWriter::new(File::create(output_path)?);
             write!(outfile, "{}:", target_fn)?;
             for dep in &deps {
                 write!(outfile, " {}", render_filename(dep, basedir)?)?;